<template>
    <el-form :model="peradd" label-width="auto" style="max-width: 600px;margin-left: 200px;">
        <div>
            <H1 style="margin-left: 200px;">添加权限</H1>
        </div>

        <el-form-item label="权限名称:">
            <el-input v-model="peradd.permissionName" />
        </el-form-item>
        <el-form-item label="权限URL:">
            <el-input v-model="peradd.permissionURL" />
        </el-form-item>
        <el-form-item label="权限序号:">
            <el-input v-model="peradd.index" />
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="bient">返回</el-button>
        </el-form-item>
    </el-form>
</template>

<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue'
import { Read, Write } from '@/Http/axios'
import { ElMessage } from "element-plus";
import { useCounterStore } from '@/stores/counter';
import router from '@/router'
const store = useCounterStore();

const peradd = reactive({
    "permissionName": "",
    "permissionURL": "",
    "index": ""
})

const onSubmit = () => {
    Write.post("/Management/AddPermission", peradd).then(res => {
        if (res.data.code == 200) {
            ElMessage.success("添加成功")
            router.push('/PermissionShow')
        }
        else {
            ElMessage.error("添加失败")
        }
    }).catch(err => {
        console.log(err)
    })
}

//返回
const bient = () => {
    router.push('/PermissionShow')
}


</script>
